package com.kylin.hibernate;

/**
 * 属性条件实体
 * 存放查询对象使用的条件
 * 条件三要素：propertyName 属性名，propertyValue 匹配值，relationalOperator 条件运算符
 * 例如
 *    propertyName="birthday"，propertyValue="2007-12-15"，relationalOperator=">"
 *    形成条件为 birthday > 2007-12-15
 *    
 *    propertyName=name，propertyValue="张%"，relationalOperator="like"
 *    形成条件为 name like "张%"
 * @author lzh
 *
 */
public class PropertyCondition {
	
	/**  like模式匹配 */
	public static final String OPERATOR_LIKE="like";
	
	/**  关系运算符 = */
	public static final String OPERATOR_EQ="=";
	
	/**  关系运算符 < */
	public static final String OPERATOR_LT="<";
	
	/**  关系运算符 <= */
	public static final String OPERATOR_LE="<=";
	
	/**  关系运算符 > */
	public static final String OPERATOR_GT=">";
	
	/**  关系运算符 >= */
	public static final String OPERATOR_GE=">=";
	
	/**  运算符 is null */
	public static final String OPERATOR_ISNULL="isNull";
	
	/**  运算符 in */
	public static final String OPERATOR_IN="in";
		
    /** 属性名 */
    private String propertyName;
    
    /** 匹配值 */
    private Object propertyValue;
    
    /** 关系运算符，可选值 EQ, LIKE，LT，LE，GT，GE 参见 PropertyCondition.OPERATOR_XX 定义 */
    private String relationalOperator;
    
    public PropertyCondition(){
    	
    }
    
	public PropertyCondition(String name, Object value, String rp){
		this.propertyName = name;
		this.propertyValue = value;
		this.relationalOperator = rp;
	}
	
	public String getPropertyName() {
		return propertyName;
	}
	public void setPropertyName(String propertyName) {
		this.propertyName = propertyName;
	}
	public Object getPropertyValue() {
		return propertyValue;
	}
	public void setPropertyValue(Object propertyValue) {
		this.propertyValue = propertyValue;
	}
	public String getRelationalOperator() {
		return relationalOperator;
	}
	public void setRelationalOperator(String relationalOperator) {
		this.relationalOperator = relationalOperator;
	}
	
	public String toString(){
		return this.propertyName + this.relationalOperator + this.propertyValue;
	}
}
